<template>
    <view class="container" :style="{ backgroundImage: 'url(' + hbbj + ')' }">
        <view class="top">
            <text @click="tabChange(0)" :class="[currentTab == 0 ? 'hb' : '']">自由动态</text>
            <text @click="tabChange(1)" :class="[currentTab == 1 ? 'hb' : '']">工作动态</text>
        </view>
        <u-form class="qpthb" :model="model" :rules="rules" ref="uForm" :errorType="errorType">
            <u-form-item class="u-m-l-30 u-m-r-30" :required="required" :label-width="200" :label-position="labelPosition" label="选择身份" prop="type">
                <u-input
                    type="select"
                    :select-open="xzsf"
                    v-model="model.type"
                    placeholder="请选择"
                    placeholderStyle="color: #0E1E36;"
                    input-align="right"
                    @click="xzsf = true"
                ></u-input>
            </u-form-item>
            <u-form-item v-if="model.type == '团队'" class="u-m-l-30 u-m-r-40" :label-width="200" :label-position="labelPosition" label="选择团队" prop="hdjf">
                <u-input
                    type="select"
                    :select-open="selectShowTeam"
                    v-model="model.team"
                    placeholder="请选择"
                    placeholderStyle="color: #0D1D36;"
                    input-align="right"
                    @click="selectShowTeam = true"
                ></u-input>
            </u-form-item>
            <!-- <u-form-item class="u-m-l-30 u-m-r-30" :required="required" :label-width="200" :label-position="labelPosition" label="身份明细" prop="type">
				<u-input
					type="select"
					:select-open="sfmx"
					v-model="model.personId"
					placeholder="请选择"
					placeholderStyle="color: #0E1E36;"
					input-align="right"
					@click="sfmx = true"
				></u-input>
			</u-form-item> -->
            <view v-if="currentTab == 1">
                <u-form-item class="u-m-l-30 u-m-r-30" :label-width="200" :label-position="labelPosition" label="我要分享" prop="categoryId">
                    <u-input
                        type="select"
                        :select-open="selectShowWyfx"
                        v-model="model.categoryId"
                        placeholder="请选择"
                        placeholderStyle="color: #0E1E36;"
                        input-align="right"
                        @click="selectShowWyfx = true"
                    ></u-input>
                </u-form-item>
                <block v-if="model.categoryId == '工程' || model.categoryId == '服务'">
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="项目名称" prop="filed1">
                        <u-input :border="border" v-model="form.filed1" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="项目地点" prop="filed2">
                        <u-input :border="border" v-model="form.filed2" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" :label-width="200" :label-position="labelPosition" label="完成时间" prop="filed3">
                        <view @click="showTime = true" style="text-align: right;width:100%;">{{ form.filed3 ? form.finishDate : '请选择时间' }}</view>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="合作对象" prop="partners">
                        <u-input :border="border" v-model="form.partners" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                </block>
                <block v-if="model.categoryId == '课程'">
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="课程名称" prop="filed1">
                        <u-input :border="border" v-model="form.filed1" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="课程编号" prop="filed2">
                        <u-input :border="border" v-model="form.filed2" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" :label-width="200" :label-position="labelPosition" label="导师名称" prop="filed3">
                        <u-input :border="border" v-model="form.filed3" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="课程内容" prop="filed4">
                        <u-input :border="border" v-model="form.filed4" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                </block>
                <block v-if="model.categoryId == '团队'">
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="团队名称" prop="filed1">
                        <u-input :border="border" v-model="form.filed1" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="团队类型" prop="filed2">
                        <u-input :border="border" v-model="form.filed2" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" :label-width="200" :label-position="labelPosition" label="擅长领域" prop="filed3">
                        <u-input :border="border" v-model="form.filed3" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="团队数量" prop="filed4">
                        <u-input :border="border" v-model="form.filed4" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                </block>
                <block v-if="model.categoryId == 'N+1'">
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="N+1名称" prop="filed1">
                        <u-input :border="border" v-model="form.filed1" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <block v-if="isCompany == 1">
                        <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="团队名称" prop="filed2">
                            <u-input :border="border" v-model="form.filed2" placeholder="请输入" type="text" input-align="right"></u-input>
                        </u-form-item>
                        <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="团队类型" prop="filed3">
                            <u-input :border="border" v-model="form.filed3" placeholder="请输入" type="text" input-align="right"></u-input>
                        </u-form-item>
                        <u-form-item class="u-m-l-30 u-m-r-30" :label-width="200" :label-position="labelPosition" label="团队地域" prop="filed4">
                            <u-input :border="border" v-model="form.filed4" placeholder="请输入" type="text" input-align="right"></u-input>
                        </u-form-item>
                    </block>
                    <block v-else>
                        <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="企业名称" prop="enterpriseName">
                            <u-input :border="border" v-model="form.enterpriseName" placeholder="请输入" type="text" input-align="right"></u-input>
                        </u-form-item>
                        <u-form-item class="u-m-l-30 u-m-r-30" :label-width="200" :label-position="labelPosition" label="企业资质" prop="qualification">
                            <u-input :border="border" v-model="form.qualification" placeholder="请输入" type="text" input-align="right"></u-input>
                        </u-form-item>
                        <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="企业性质" prop="enterprise">
                            <u-input :border="border" v-model="form.enterprise" placeholder="请输入" type="text" input-align="right"></u-input>
                        </u-form-item>
                    </block>
                </block>
                <block v-if="model.categoryId == '活动'">
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="活动名称" prop="name">
                        <u-input :border="border" v-model="form.name" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="活动人数" prop="num">
                        <u-input :border="border" v-model="form.num" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" :label-width="200" :label-position="labelPosition" label="活动时间" prop="finishDate">
                        <view @click="showTime = true" style="text-align: right;width:100%;">{{ form.finishDate ? form.finishDate : '请选择时间' }}</view>
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-30" label-width="200" :label-position="labelPosition" label="活动地点" prop="address">
                        <u-input :border="border" v-model="form.address" placeholder="请输入" type="text" input-align="right"></u-input>
                    </u-form-item>
                </block>
                <block v-if="model.categoryId == '工程' || model.categoryId == '服务'">
                    <u-form-item class="u-m-l-30 u-m-r-40 u-flex" style="justify-content: flex-end;" :label-position="labelPosition" :border-bottom="false" label="" prop="isOpen">
                        <u-radio-group v-model="isOpen" @change="radioGroupChange">
                            <u-radio @change="radioChange" v-for="(item, index) in radioList" :key="index" :name="item.name" :shape="shape" :disabled="item.disabled">
                                {{ item.name }}
                            </u-radio>
                        </u-radio-group>
                    </u-form-item>
                </block>
                <u-gap :bg-color="bgColor" :height="height"></u-gap>
                <view class="gzxd">
                    <view class="u-p-t-30 u-p-l-30">成果展示</view>
                    <u-form-item :label-position="labelPosition" prop="photo" label-width="150" :border-bottom="false">
                        <u-form-item :label-position="labelPosition" prop="photo" label-width="150">
                            <u-upload
                                ref="uUpload"
                                @on-uploaded="onUploaded"
                                :custom-btn="customBtn"
                                :show-upload-list="showUploadList"
                                :action="action"
                                :auto-upload="autoUpload"
                                :file-list="fileList"
                                @on-remove="onRemove"
                                :show-progress="showProgress"
                                :deletable="deletable"
                                :max-count="maxCount"
                                @on-list-change="onListChange"
                                :site="baseUrl"
                            >
                                <view v-if="customBtn" slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
                                    <u-icon name="photo" size="60" :color="$u.color['lightColor']"></u-icon>
                                </view>
                            </u-upload>
                        </u-form-item>
                    </u-form-item>
                </view>
                <u-gap :bg-color="bgColor" :height="height"></u-gap>

                <view class="gzxd u-p-l-20 u-p-r-20">
                    <view class="u-p-t-30 u-p-l-10">工作心得</view>
                    <u-form-item class="zwpj  u-m-t-30 " :label-position="labelPosition" prop="article">
                        <u-input type="textarea" :maxlength="1500" :auto-height="true" placeholder="请输入工作心得！" v-model="model.article" />
                    </u-form-item>
                    <u-form-item class="u-m-l-30 u-m-r-40" :label-position="labelPosition" :border-bottom="false" label="" label-width="270" prop="fbtype">
                        <u-checkbox-group>
                            <u-checkbox @change="getFbtype" v-model="item.checked" v-for="(item, index) in fbtypes" :key="index" :name="item.name">{{ item.name }}</u-checkbox>
                        </u-checkbox-group>
                    </u-form-item>

                    <u-form-item v-if="model.fbtype == 'hyfb'" label-width="200" :label-position="labelPosition" label="领域" prop="cy">
                        <view style="width:100%;text-align: right;" @click="mSelect">{{ model.cy || '请选择' }}</view>
                    </u-form-item>
                    <u-form-item v-if="model.fbtype == 'hyfb'" label-width="200" :label-position="labelPosition" label="地域" prop="pcd">
                        <view style="width:100%;text-align: right;" @click="cityActive = true">{{ model.pcd || '请选择' }}</view>
                    </u-form-item>
                </view>
            </view>
            <view v-else>
                <view class="u-p-t-30 u-p-l-30">上传图片</view>

                <u-form-item class="u-m-r-30 " :label-position="labelPosition" prop="photo" label-width="150">
                    <u-upload
                        ref="uUpload"
                        @on-choose-complete="uploadLength"
                        @on-uploaded="onUploaded"
                        :custom-btn="customBtn"
                        :show-upload-list="showUploadList"
                        :action="action"
                        :auto-upload="autoUpload"
                        :file-list="fileList"
                        @on-remove="onRemove"
                        :show-progress="showProgress"
                        :deletable="deletable"
                        :max-count="maxCount"
                        @on-list-change="onListChange"
                        :site="baseUrl"
                    >
                        <view v-if="customBtn" slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
                            <u-icon name="photo" size="60" :color="$u.color['lightColor']"></u-icon>
                        </view>
                    </u-upload>
                </u-form-item>
                <u-gap :bg-color="bgColor" :height="height"></u-gap>
                <view class="u-p-t-30 u-p-l-30">上传文字</view>
                <u-form-item :required="required" :border-bottom="false" class="zwpj  u-m-t-30 " :label-position="labelPosition" prop="article">
                    <u-input type="textarea" :maxlength="1500" :auto-height="true" :border="border" placeholder="请输入文字！" v-model="model.article" />
                </u-form-item>
                <u-form-item class="u-m-l-30 u-m-r-40" :label-position="labelPosition" :border-bottom="false" label="" label-width="270" prop="fbtype">
                    <u-checkbox-group>
                        <u-checkbox @change="getFbtype" v-model="item.checked" v-for="(item, index) in fbtypes" :key="index" :name="item.name">{{ item.name }}</u-checkbox>
                    </u-checkbox-group>
                </u-form-item>
                <u-form-item class="u-m-l-30 u-m-r-40" v-if="model.fbtype == 'hyfb'" label-width="200" :label-position="labelPosition" label="领域" prop="cy">
                    <view style="width:100%;text-align: right;" @click="mSelect">{{ model.cy || '请选择' }}</view>
                </u-form-item>
                <u-form-item class="u-m-l-30 u-m-r-40" v-if="model.fbtype == 'hyfb'" label-width="200" :label-position="labelPosition" label="地域" prop="pcd">
                    <view style="width:100%;text-align: right;" @click="cityActive = true">{{ model.pcd || '请选择' }}</view>
                </u-form-item>
            </view>
            <u-form-item class="u-m-l-30 u-m-r-40" :label-width="200" :label-position="labelPosition" :border-bottom="false" label="限制公社列表" prop="communeIds">
                <view style="text-align: right;width:100%;" @click="showUpopup">{{ model.communeIds || '请选择' }}</view>
            </u-form-item>
            <view style="height:50rpx;"></view>
            <view class="u-m-t-20 u-p-30">
                <!--弹出框-->
                <u-select mode="single-column" :list="wyfxList" v-model="selectShowWyfx" @confirm="wyfxConfirm"></u-select>
                <u-select mode="single-column" :list="xzsfList" v-model="xzsf" @confirm="xzsfConfirm"></u-select>
                <u-select mode="single-column" :list="sfmxList" v-model="sfmx" @confirm="sfmxConfirm"></u-select>
                <u-select
                    :default-value="defaultValue"
                    v-model="showCity"
                    mode="mutil-column-auto"
                    value-name="value"
                    label-name="name"
                    child-name="submenu"
                    :list="listCitys"
                    @confirm="confirmCity"
                ></u-select>
                <u-select mode="single-column" :list="cylist" v-model="showcy" @confirm="cyConfirm"></u-select>
                <u-picker mode="time" :defaultTime="defaultTime" v-model="showTime" :params="params" end-year="2030" @confirm="confirmTime"></u-picker>
                <!--弹出框-->
            </view>
            <view class="u-flex u-row-center btnall">
                <view class="btnaccept u-m-r-50" @click="submit">发布</view>
                <view class="btngoutou" @click="pre">预览</view>
            </view>
        </u-form>
        <u-popup border-radius="0" v-model="show" :mode="mode" length="50%" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view style="height:100%;overflow: auto;">
                <view class="u-p-30 u-row-center u-border-bottom" style="font-size:30rpx;color:#4c9cff;" @click="close">确定</view>
                <u-checkbox-group class="gl-list" :size="size" :width="width" :wrap="wrap" :max="max" @change="checkboxGroupChange" :activeColor="activeColor">
                    <u-checkbox
                        @change="checkboxChange"
                        v-model="item.checked"
                        v-for="(item, index) in communeList"
                        :key="index"
                        :name="item.name"
                        :shape="shape"
                        :disabled="item.disabled"
                    >
                        <text style="padding-left:20rpx;">{{ item.name }}</text>
                    </u-checkbox>
                </u-checkbox-group>
            </view>
        </u-popup>
        <TriTree
            ref="triTree"
            :range="fetchDict.company_type"
            @confirm=" function(e) { return setChooseType(e, 'cy'); }"
        ></TriTree>
        <u-select mode="single-column" :list="selectListTeam" v-model="selectShowTeam" value-name="id" label-name="name" @confirm="confirmTeam"></u-select>
        <city-select v-model="cityActive" @city-change="cityChange"></city-select>
        <u-toast ref="uToast" />
    </view>
</template>

<script>
import citySelect from '@/components/u-city-select.vue';
export default {
    components: {
        citySelect
    },
    data() {
        return {
            cityActive: false,
            form: {},
            selectListTeam: [],
            selectShowTeam: false,
            selectShowDy: false,
            showcy: false,
            //选择时间
            showTime: false,
            defaultTime: '',
            params: {
                year: true,
                month: true,
                day: true,
                hour: true,
                minute: true,
                second: true,
                timestamp: true
            },
            //选择城市
            showCity: false,
            defaultValue: [3],
            listCitys: [],
            //限制公社列表
            disabled: false,
            checked: true,
            result: [],
            shape: 'circle',
            max: 3,
            activeColor: '#2979ff',
            size: 34,
            wrap: true,
            width: 'auto',

            height: 20,
            bgColor: this.$u.color.bgColor,
            marginTop: 30,
            marginBottom: 30,
            fbtypes: this.$mConstDataConfig.fbtypes,
            hbbj: '../../static/img/fbdt.png',
            currentTab: 0,
            show: false,
            mode: 'bottom',
            mask: true, // 是否显示遮罩
            closeable: true,
            closeIconPos: 'top-right',
            model: {
                article: '',
                categoryId: '',
                communeId: 0,
                dttype: 'zydt',
                fbtype: 'qwfb',
                finishDate: '',
                identityType: 0,
                imgUrl: '',
                isOpen: true,
                partners: '',
                pcd: '',
                communeIds: '',
                personId: '',
                cy: ''
            },
            radioList: [
                {
                    name: '公开',
                    checked: true,
                    disabled: false
                },
                {
                    name: '隐藏',
                    checked: false,
                    disabled: false
                }
            ],
            cylist: [
                {
                    value: '产业1',
                    label: '产业1'
                },
                {
                    value: '产业2',
                    label: '产业2'
                },
                {
                    value: '产业3',
                    label: '产业3'
                }
            ],
            checkboxList1: [
                {
                    name: '公开',
                    checked: false,
                    disabled: false
                },
                {
                    name: '隐藏',
                    checked: true,
                    disabled: false
                }
            ],
            rules: {
                article: [
                    {
                        required: true,
                        message: '内容不能为空',
                        trigger: 'change'
                    }
                ]
            },
            required: false,
            border: false,
            check: false,
            selectStatus: 'close',
            selectShowWyfx: false,
            categoryId: '1',
            wyfxList: [
                {
                    value: '1',
                    label: '课程'
                },
                {
                    value: '2',
                    label: '团队'
                },
                {
                    value: '3',
                    label: 'N+1'
                },
                {
                    value: '3',
                    label: '活动'
                },
                {
                    value: '5',
                    label: '服务'
                },
                {
                    value: '6',
                    label: '工程'
                }
            ],
            xzsf: false,
            type: '',
            xzsfList: [
                {
                    value: '0',
                    label: '个人'
                },
                {
                    value: '1',
                    label: '企业'
                },
                {
                    value: '2',
                    label: '团队'
                }
            ],
            sfmx: false,
            sfmxList: [
                {
                    value: '0',
                    label: '身份1'
                },
                {
                    value: '1',
                    label: '身份2'
                },
                {
                    value: '2',
                    label: '身份3'
                }
            ],
            selectShowWxy: false,
            selectShowWyx: false,
            selectShowQyxz: false,
            selectShowQylx: false,
            selectShowQydy: false,
            selectShowLyxy: false,
            labelPosition: 'left',
            codeTips: '',
            errorType: ['toast'],
            fileList: [],
            showUploadList: true,
            customBtn: false,
            autoUpload: true,
            showProgress: false,
            deletable: true,
            customStyle: false,
            maxCount: 9,
            lists: [], // 组件内部的文件列表
            filePaths: '', // 文件路径
            fileNames: '', // 文件名称
            action: this.$apis.uploadFile,
            baseUrl: this.$mConfig.baseUrl,
            communeList: [],
            communeIds: '',
            isOpen: '公开',
            fetchDict: [],
            teamKey: '',
            isCompany: 0,
            placeholder: '开始输入...'
        };
    },
    onReady() {
        this.$refs.uForm.setRules(this.rules);
    },
    onLoad() {
        this.communeUList();
        this.cityList();
        this.defaultTime = this.getTime();
        console.log('userInfo', this.$store.state.userInfo);
        if (this.$store.state.userInfo.identityType == 1) {
            this.isCompany = 1;
            this.xzsfList = [
                {
                    value: '1',
                    label: '企业'
                },
                {
                    value: '2',
                    label: '团队'
                }
            ];
        } else {
            this.xzsfList = [
                {
                    value: '0',
                    label: '个人'
                },
                {
                    value: '2',
                    label: '团队'
                }
            ];
        }

        this.dictionaryFetchDict('company_type'); //产业
        this.getTeamList();
    },
    methods: {
        cityChange(e) {
            let address = e.province.label;
            if (e.city) {
                address = address + '-' + e.city.label;
            }
            if (e.area) {
                address = address + '-' + e.area.label;
            }
            this.model.pcd = address;
        },
        uploadLength(lists, name) {
            console.log('lists', lists);
            if (lists.length > 9) {
                uni.showToast({
                    title: '最多只能选择9张图片',
                    icon: 'none'
                });
                this.fileList = [];
            }
        },
        confirmTeam(e) {
            e.map((val, index) => {
                this.model.team = val.label;
                this.model.personId = val.value;
                this.teamKey = index;
            });
        },
        async getTeamList() {
            let result = await this.$apis.findUserTeam();
            this.selectListTeam = result.data;
            if (result.data.length == 0 && this.model.iam == '智汇团队') {
                uni.showToast({
                    title: '您还没有创建团队',
                    icon: 'none'
                });
                setTimeout(function() {
                    uni.navigateBack();
                }, 2000);
            }
        },
        pre() {
            var row = encodeURIComponent(JSON.stringify(this.model));
            uni.navigateTo({
                url: '/pages/releaseNumber/detail?row=' + row
            });
        },
        setChooseType(item, type) {
            var column_array = this.$mUtils.array_column(item, 'label');
            var modelValue = column_array.join(',');
            this.model[type] = modelValue;
            this.$forceUpdate();
        },
        mSelect() {
            this.$refs.triTree._show();
        },
        async dictionaryFetchDict(keyWords) {
            let result = await this.$apis.dictGroup({
                dictCode: keyWords
            });
            this.fetchDict[keyWords] = result.data.reverse();
            this.$forceUpdate();
        },
        getTime: function() {
            var _this = this;
            let yy = new Date().getFullYear();
            let mm = new Date().getMonth() + 1;
            let dd = new Date().getDate();
            let hh = new Date().getHours();
            let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
            let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
            _this.gettime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
        },
        // 选中任一radio时，由radio-group触发
        radioGroupChange(e) {},
        // 选中某个单选框时，由radio时触发
        radioChange(e) {
            console.log(e);
            this.isOpen = e;
            if (e == '公开') {
                this.model.isOpen = true;
            } else {
                this.model.isOpen = false;
            }
        },
        confirmTime(e) {
            // console.log(e);
            let input = '';
            if (this.params.year) input += e.year;
            if (this.params.month) input += '-' + e.month;
            if (this.params.day) input += '-' + e.day;
            if (this.params.hour) input += ' ' + e.hour;
            if (this.params.minute) input += ':' + e.minute;
            if (this.params.second) input += ':' + e.second;
            this.model.finishDate = input;
        },
        confirmCity(e) {
            this.model.pcd = '';
            e.map((val, index) => {
                this.model.pcd += this.model.pcd == '' ? val.label : '-' + val.label;
            });
        },
        wyfxConfirm(e) {
            this.model.categoryId = e[0].label;
            this.categoryId = e[0].value;
            console.log('teamKey', this.teamKey, 'categoryId', this.model.categoryId);
            if (this.teamKey !== '' && this.model.categoryId == '团队') {
                console.log('selectListTeam', this.selectListTeam[this.teamKey]);
                this.form.name = this.selectListTeam[this.teamKey].name;
                this.form.leaderArea = this.selectListTeam[this.teamKey].leaderArea;
                this.form.num = this.selectListTeam[this.teamKey].num;
                this.form.teamType = this.selectListTeam[this.teamKey].teamType;
            }
        },
        cyConfirm(e) {
            this.model.cy = e[0].label;
        },
        xzsfConfirm(e) {
            this.model.type = e[0].label;
            this.type = e[0].value;
            //if(this.model.type == '团队') this.$delete(this.wyfxList,1);
        },
        sfmxConfirm(e) {
            this.model.type = e[0].label;
            this.type = e[0].value;
        },
        close() {
            this.show = false;
        },
        checkboxGroupChange() {},
        checkboxChange(val) {
            console.log(val);
            var id = '';
            for (var i in this.communeList) {
                if (this.communeList[i].name == val.name) {
                    id = this.communeList[i].id;
                }
            }
            if (this.model.communeIds == '') {
                this.communeIds = ',' + id;
                this.model.communeIds = val.name;
            } else {
                this.communeIds = this.communeIds + ',' + id;
                this.model.communeIds = this.model.communeIds + ',' + val.name;
            }
            this.communeIds = this.communeIds + ',';
        },
        showUpopup() {
            this.show = true;
        },
        showCy() {
            this.showcy = true;
        },
        async communeUList() {
            let result = await this.$apis.CommuneUList();
            this.communeList = result.data;
        },
        async cityList() {
            let result = await this.$apis.fetchArea({ level: 2 });
            this.listCitys = result.data;
        },
        submit() {
            this.$refs.uForm.validate(valid => {
                if (valid) {
                    this.model.groups = this.form;
                    this.save();
                    console.log('验证通过');
                } else {
                    console.log('验证失败');
                }
            });
        },
        async save() {
            let reqBody = this.model;
            reqBody.communeIds = this.communeIds;
            reqBody.type = this.type;
            if (this.model.categoryId == '工程' || this.model.categoryId == '服务') {
                reqBody.extraData = [
                    {
                        value: this.form.filed1,
                        title: '项目名称'
                    },
                    {
                        value: this.form.filed2,
                        title: '项目地点'
                    },
                    {
                        value: this.form.filed3,
                        title: '完成时间'
                    },
                    {
                        value: this.form.filed4,
                        title: '合作对象'
                    }
                ];
            } else if (this.model.categoryId == '团队') {
                reqBody.extraData = [
                    {
                        value: this.form.filed1,
                        title: '团队名称'
                    },
                    {
                        value: this.form.filed2,
                        title: '团队类型'
                    },
                    {
                        value: this.form.filed3,
                        title: '擅长领域'
                    },
                    {
                        value: this.form.filed4,
                        title: '团队数量'
                    }
                ];
            } else if (this.model.categoryId == 'N+1') {
                if (this.isCompany == 1) {
                    reqBody.extraData = [
                        {
                            value: this.form.filed1,
                            title: 'N+1名称'
                        },
                        {
                            value: this.form.filed2,
                            title: '团队名称'
                        },
                        {
                            value: this.form.filed3,
                            title: '团队类型'
                        },
                        {
                            value: this.form.filed4,
                            title: '团队地域'
                        }
                    ];
                } else {
                    reqBody.extraData = [
                        {
                            value: this.form.filed1,
                            title: 'N+1名称'
                        },
                        {
                            value: this.form.filed2,
                            title: '企业名称'
                        },
                        {
                            value: this.form.filed3,
                            title: '企业资质'
                        },
                        {
                            value: this.form.filed4,
                            title: '企业性质'
                        }
                    ];
                }
            } else if (this.model.categoryId == '活动') {
                reqBody.extraData = [
                    {
                        value: this.form.filed1,
                        title: '活动名称'
                    },
                    {
                        value: this.form.filed2,
                        title: '活动人数'
                    },
                    {
                        value: this.form.filed3,
                        title: '活动时间'
                    },
                    {
                        value: this.form.filed4,
                        title: '活动地点'
                    }
                ];
            } else if (this.model.categoryId == '课程') {
                reqBody.extraData = [
                    {
                        value: this.form.filed1,
                        title: '课程名称'
                    },
                    {
                        value: this.form.filed2,
                        title: '课程编号'
                    },
                    {
                        value: this.form.filed3,
                        title: '导师名称'
                    },
                    {
                        value: this.form.filed4,
                        title: '课程内容'
                    }
                ];
            }
            let result = await this.$apis.addWorkCircle(reqBody);
            if (result.code == 200) {
                this.$refs.uToast.show({
                    title: result.message,
                    type: 'success'
                    //url: '/pages/releaseNumber/index'
                });
                setTimeout(function() {
                    uni.navigateBack();
                }, 2000);
            }
        },
        tabChange(e) {
            console.log(e);
            this.model.dttype = e ? 'gzdt' : 'zydt';
            this.currentTab = e;
        },
        getFbtype(e) {
            var fbtype = 'qwfb';

            if (e.value == true) {
                var fbtypes = [];
                for (var i in this.fbtypes) {
                    if (this.fbtypes[i]['name'] == e.name) {
                        fbtype = this.fbtypes[i]['value'];
                        console.log(fbtype);
                        this.fbtypes[i]['checked'] = true;
                    } else {
                        this.fbtypes[i]['checked'] = false;
                    }
                    fbtypes.push(this.fbtypes[i]);
                }
            }
            if ('hyfb' == fbtypes && this.$store.state.userInfo.vipLevel < 2) {
                this.$refs.uToast.show({
                    title: '会员专享，请升级',
                    type: 'warning'
                });
                return;
            }
            this.fbtypes = fbtypes;
            console.log(fbtypes);
            this.model.fbtype = fbtype;
        },
        upload() {
            this.$refs.uUpload.upload();
            console.log('上传');
        },
        deleteItem(index) {
            this.$refs.uUpload.remove(index);
            console.log('删除');
        },
        onOversize(file, lists) {
            console.log('onOversize', file, lists);
        },
        onPreview(url, lists) {
            console.log('onPreview', url, lists);
        },
        onRemove(index, lists) {
            console.log('onRemove', index, lists);
            this.fileList.splice(index, 1);
            console.log(this.fileList);
            this.filePaths = this.fileList;
        },
        onSuccess(data, index, lists) {
            console.log('onSuccess', data, index, lists);
        },
        onChange(res, index, lists) {
            console.log('onChange', res, index, lists);
        },
        error(res, index, lists) {
            console.log('onError', res, index, lists);
        },
        onProgress(res, index, lists) {
            console.log('onProgress', res, index, lists);
        },
        onUploaded(lists) {
            var filePaths = [],
                fileNames = [];
            for (let i in lists) {
                console.log('data', lists[i].response);
                if (lists[i].response.code == 200) {
                    if (filePaths.length < 10) filePaths.push(lists[i].response.message);
                }
            }
            this.filePaths = filePaths.join(',');
            this.model.imgUrl = this.filePaths;
        },
        onListChange(lists) {
            console.log('onListChange', lists);
            this.lists = lists;
        }
    }
};
</script>

<style scoped lang="scss">
page {
    background-color: #f4f4f4;
}
.container {
    background-repeat: no-repeat;
    background-size: 100% 500rpx;
    background-position: 0 -20px;
}
.gzxd {
    background: white;
    border-radius: 30rpx;
    // border: 1px solid;
    // padding-bottom: 100px;
}
.top {
    display: flex;
    justify-content: space-around;
    padding: 58rpx 30rpx;

    text {
        display: block;
        width: 226rpx;
        height: 60rpx;
        line-height: 60rpx;
        color: #ffffff;
        font-size: 28rpx;
        text-align: center;
    }

    .hb {
        background: #ffffff;
        border-radius: 30rpx;
        color: #ab62ff;
    }
}

.btnall {
    width: 750rpx;
    height: 100rpx;
    background: #ffffff;
    position: fixed;
    // padding-top: 100px;
    bottom: 0;
    z-index: 10;
}

.btnaccept {
    width: 270rpx;
    height: 64rpx;
    background: #4c9cff;
    border-radius: 40upx;
    line-height: 64rpx;
    text-align: center;
    color: #fff;
    font-size: 26rpx;
}

.btngoutou {
    width: 270rpx;
    height: 64rpx;
    background-color: #6ade7e;
    border-radius: 40upx;
    line-height: 64rpx;
    text-align: center;
    color: #fff;

    font-size: 26rpx;
}

.zwpj {
    width: 670rpx;
    background: #f5f5f9;
    border-radius: 20rpx;
    margin: 0 auto;
    overflow: hidden;
}

.bknhb {
    width: 710rpx;
    height: 670rpx;
    background-color: #ffffff;
    border-radius: 20rpx;
}

.button {
    width: 662rpx;
    margin: 50rpx auto 102rpx auto;
    background: #ea5e3a;
    border-radius: 40rpx;
    border: 0;
    color: #fff;

    &.u-hairline-border:after {
        border: 0;
    }
}

// .jq{
// 	color: #0D1D36;
// 	font-size: 50rpx;
// 	font-weight: bold;
// 	margin-left: 256rpx;
// 	margin-top: 160rpx;
// }
.qpthb {
    width: 710rpx;
    margin: 0 auto;
    background-color: #ffffff;
    border-radius: 20rpx;
}
.gl-list {
    .u-checkbox {
        padding: 20rpx 30rpx;
    }
}
</style>
